// 当前这个模块 API ist统一进行管理
import axios from './axios'
import mockAxios from './mockAxios'
// 三级联动接口
// 'api/product/getBaseCategoryList'  get   无参数
// 发请求：axios发请求返回结果 Prmise 对象
// 对外暴露一个函数，只要外部调用这个函数就像服务器 ajax 发请求，获取咋们的三级菜单数据当前咋们这个函数只需要把服务器返回结果返回即可
export const reqCategoryList = () => axios({ url: '/product/getBaseCategoryList', method: 'get' })

//   mock  (模拟)
// 获取banner (home首页轮播图)
export const reqGetBannerList = () => mockAxios.get('/banner')
// 获取floor数据
export const reqFloorList = () => mockAxios.get('/floor')

// 获取搜索模块数据  地址：/api/list      参数：需要带参
// 当前这接口（获取搜索模块的数据），给服务器传递一个默认参数，这个方法传入至少一个空对象
export const reqGetSearchInfo = (params) => axios({ url: '/list', method: 'post', data: params })


// 获取商品详情信息的接口  URL：/api/item/{ skuId }  请求方式：GET
export const reqGoodsInfo = (skuId) => axios({ url: `/item/${skuId}`, method: 'get' })


// 获取 将商品添加到购物车（对购物车商品数量进行改动）
//  /api/cart/addToCart/{ skuId }/{ skuNum }   POST
export const reqAddOrUpdateShopCart = (skuId, skuNum) => axios({
  url: `/cart/addToCart/${skuId}/${skuNum}`,
  method: 'post'
})

// 获取购物车列表 数据
export const reqCartList = () => axios({ url: '/cart/cartList', method: 'get' })

// 删除购物车商品 /api/cart/deleteCart/{skuId}   
export const reqdeleteCart = (skuId) => axios({ url: `/cart/deleteCart/${skuId}`, method: 'DELETE' })

// 切换商品选中状态   /cart/checkCart/{skuID}/{isChecked}   methdos ：GET
export const reqUpdateCheckedByid = (skuId, isChecked) => axios({ url: `/cart/checkCart/${skuId}/${isChecked}`, method: 'get' })

// 获取验证码   url:/api/user/passport/sendCode/{phone}   method : get
export const reqGetCode = (phone) => axios({ url: `/user/passport/sendCode/{phone}`, method: 'get' })

// 用户注册 url: /api/user/passport/register    method: post
// export const reqUserRegister = (data)=> axios({url:'/user/passport/register',method:'post',data})
export const reqUserRegister = (data) => axios({ url: `/user/passport/register`, method: 'post', data });

// 用户登录   url : /api/user/passport/login    method : post
export const reqUserLogin = (data) => axios({ url: '/user/passport/login', data, method: 'post' })

// 获取用户登录信息 url:/api/user/passport/auth/getUserInfo   method :get
export const reqUserIinfo = () => axios({ url: '/user/passport/auth/getUserInfo', method: 'get' })

// 退出登录 url/api/user/passport/logout  //methods ：get
export const reqLogOut = () => axios({ url: '/user/passport/logout', method: 'get' })

// 获取用户 地址信息 url ： /api/user/userAddress/auth/findUserAddressList   method ： get 
export const reqUserAddressList = () => axios({ url: '/user/userAddress/auth/findUserAddressList', method: 'get' })

// 获取订单交易页信息 url : /api/order/auth/trade method : get
export const reqOrderInfo = () => axios({ url: '/order/auth/trade', method: 'get' })

// 提交订单 url: /api/order/auth/submitOrder?tradeNo={tradeNo}  method : post
export const reqSubmitOrder = (tradeNo,data) => axios({url:`/order/auth/submitOrder?tradeNo=${tradeNo}`,data,method:'post'})

// 获取订单交易信息 url: /api/payment/weixin/createNative/{orderId} method: get
export const reqPayInfo = (orderId) =>axios({url:`/payment/weixin/createNative/${orderId}`,method:'get'})

// 获取订单支付信息 URL : /api/payment/weixin/createNative/{orderId}  method : 'get
export const reqPayStatus = (orderId) =>axios({url:`/payment/weixin/createNative/${orderId}`,method:'get'})